package com.zhaolang.qogir.ui.processed;

import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import com.zhaolang.qogir.R;
import com.zhaolang.qogir.ui.BaseFragment;

public class FragmentProcessedHurry extends BaseFragment implements PullToRefreshBase.OnRefreshListener2<ListView>{

    private PullToRefreshListView pullListView;
    private ListView listView;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        setContentView(R.layout.fragment_processed_hurry);
        initView();
        return getContentView();
    }

    private void initView() {
        pullListView = findViewById(R.id.pullListView);
        listView = pullListView.getRefreshableView();
        pullListView.setOnRefreshListener(this);
        pullListView.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
    }

    @Override
    public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
        new GetDataTask().execute();
    }

    @Override
    public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
        new GetDataTask().execute();
    }

    private class GetDataTask extends AsyncTask<Void, Void, String> {

        @Override
        protected String doInBackground(Void... params) {
            return null;
        }

        @Override
        protected void onPostExecute(String result) {
            // Call onRefreshComplete when the list has been refreshed.
            pullListView.onRefreshComplete();
        }
    }
}
